package doudizhu;

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;

/**
 * 5. 编程题
 *
 *  使用集合实现斗地主游戏的部分功能，要求如下：
 *
 *  （1）首先准备 54 张扑克牌并打乱顺序。
 *
 *  （2）由三个玩家交替摸牌，每人 17 张扑克牌，最后三张留作底牌。
 *
 *  （3）查看三个玩家手中的扑克牌和底牌。
 *
 *  （4）其中玩家手中的扑克牌需要按照大小顺序打印，规则如下：
 *
 *     手中扑克牌从大到小的摆放顺序：大王,小王,2,A,K,Q,J,10,9,8,7,6,5,4,3
 */
public class Poker implements Comparable {

    private static Poker BigPoker = new Poker("大王","红");;

    private static Poker smallPoker = new Poker("小王","黑");


    //定义牌
    private String brand;

    //花色
    private String brandColor;

    //大小
    private Integer value;

    public Integer getValue() {

        HashMap<String,Integer> brandColorValueMap = new HashMap<>();
        brandColorValueMap.put("黑桃",4);
        brandColorValueMap.put("红桃",3);
        brandColorValueMap.put("梅花",2);
        brandColorValueMap.put("方片",1);
        brandColorValueMap.put("红",1);
        brandColorValueMap.put("黑",1);
        //手中扑克牌从大到小的摆放顺序：大王,小王,2,A,K,Q,J,10,9,8,7,6,5,4,3
        HashMap<String,Integer> brandValueMap = new HashMap<>();
        brandValueMap.put("3",300);
        brandValueMap.put("4",400);
        brandValueMap.put("5",500);
        brandValueMap.put("6",600);
        brandValueMap.put("7",700);
        brandValueMap.put("8",800);
        brandValueMap.put("9",900);
        brandValueMap.put("10",1000);
        brandValueMap.put("J",1100);
        brandValueMap.put("Q",1200);
        brandValueMap.put("K",1300);
        brandValueMap.put("A",1400);
        brandValueMap.put("2",1500);
        brandValueMap.put("小王",1000000);
        brandValueMap.put("大王",2000000);
        this.value = brandColorValueMap.get(this.getBrandColor())+brandValueMap.get(this.getBrand());
        return value;
    }

    public Poker(){}

    public Poker(String brand, String brandColor) {
        this.brand = brand;
        this.brandColor = brandColor;
    }

    public Poker(String brand, String brandColor, int value) {
        this.brand = brand;
        this.brandColor = brandColor;
        this.value = value;
    }

    public static Poker getBigPoker() {
        return BigPoker;
    }

    public static Poker getSmallPoker() {
        return smallPoker;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getBrandColor() {
        return brandColor;
    }

    public void setBrandColor(String brandColor) {
        this.brandColor = brandColor;
    }

//    @Override
//    public String toString() {
//        return "Poker{" +
//                "brand='" + brand + '\'' +
//                ", brandColor='" + brandColor + '\'' +
//                ", value=" + this.getValue() +
//                '}';
//    }


    @Override
    public String toString() {
        return brand;
    }

    @Override
    public int compareTo(Object o) {
        Poker o1 = (Poker) o;
        return o1.getValue().compareTo(this.getValue());
    }
}
